﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ViewModels="clr-namespace:ScrumSprintMonitor.Modules.BuildMonitor.ViewModels"
    xmlns:Controls="clr-namespace:ScrumSprintMonitor.Modules.BuildMonitor.Controls">

    <DataTemplate x:Key="LastBuildInfo">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <TextBlock Grid.Row="0" Grid.Column="0" Text="Last build:" Foreground="White" Opacity="0.5" Margin="3"/>
            <TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding LastBuildNumber}" Foreground="White" Margin="3" />
            <TextBlock Grid.Row="0" Grid.Column="2" Foreground="#7FFFFFFF" Margin="3">
                <TextBlock.Text>
                    <Binding Path="RequestedFor">
                        <Binding.StringFormat>(requested for {0}).</Binding.StringFormat>
                    </Binding>
                </TextBlock.Text>
            </TextBlock>
            <TextBlock Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" Text="{Binding Path=BuildStatusText}" Foreground="White" Opacity="0.7" Margin="3"/>
        </Grid>
    </DataTemplate>

    <DataTemplate x:Key="NoBuildInfo">
        <StackPanel HorizontalAlignment="Left" Orientation="Horizontal" Margin="6">
            <TextBlock Foreground="#7FFFFFFF" Text="Connection to build server not set up."/>
        </StackPanel>
    </DataTemplate>

    <DataTemplate DataType="{x:Type ViewModels:BuildStatusBackgroundViewModel}">
        <Controls:BuildStatusBorder />
    </DataTemplate>

    <DataTemplate DataType="{x:Type ViewModels:BuildStatusDetailsViewModel}">
        <ContentPresenter Content="{Binding}">
            <ContentPresenter.Style>
                <Style TargetType="{x:Type ContentPresenter}">
                    <Setter Property="ContentTemplate" Value="{StaticResource LastBuildInfo}" />

                    <Style.Triggers>
                        <DataTrigger Binding="{Binding Path=BuildStatus}" Value="NotSetUp">
                            <Setter Property="ContentTemplate" Value="{StaticResource NoBuildInfo}" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </ContentPresenter.Style>
        </ContentPresenter>
    </DataTemplate>
</ResourceDictionary>